home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / funmod.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  785 b   |  37 lines

  1. /*
  2. \funcref{fun\_mod}{void fun\_mod ()}
  3.     {}
  4.     {}
  5.     {pop(), push(), error()}
  6.     {}
  7.     {funmod.c}
  8.     {
  9.         This function pops two variables and pushes the modulo value of the
  10.         {\em vu.intval} fields of these variables. The resulting pushed
  11.         variable is of type {\em e\_int}.
  12.  
  13.         It is assumed that the left argument of the modision was pushed first;
  14.         therefore, the right argument is popped first. A division by zero leads
  15.         to an error.
  16.     }
  17. */
  18.  
  19. #include "icm-exec.h"
  20.  
  21. void fun_mod ()
  22. {
  23.     VAR_
  24.         tmp;
  25.     int
  26.         rvalint;
  27.  
  28.     tmp.type = e_int;
  29.     rvalint = pop ().vu.intval;
  30.     if (! rvalint)
  31.         error ("divide by zero at %s", hexstring (curoffs, 4));
  32.  
  33.     tmp.vu.intval = pop().vu.intval % rvalint;
  34.  
  35.     push (tmp);
  36. }
  37.